const { ref } = Vue
import { useFetch } from '../../../Scripts/hooks/useFetch.js'

export function useFetchMethods() {
  const resourceList = ref([]);
  const getDispatchAndReportInfo = async configObj => {
    const { data } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        type: `${configObj.method}`,
        containerstepdispatchid: configObj.containerstepdispatchid,
        workerid: configObj.workerid
      }
    });
    return data.value;
  }

  const getResourceList = async configObj => {
    const { data } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        type: `${configObj.method}`,
        containerstepdispatchid: configObj.containerstepdispatchid,
        containerid: configObj.containerid,
        workflowstepid: configObj.workflowstepid
      }
    });
    resourceList.value = data.value;
  }

  return {
    resourceList,
    getDispatchAndReportInfo,
    getResourceList
  }
}